def solve(num):
    res = ""

    roman_num_dict = [
        (1000, "M"),
        (900, "CM"),
        (500, "D"),
        (400, "CD"),
        (100, "C"),
        (90, "XC"),
        (50, "L"),
        (40, "XL"),
        (10, "X"),
        (9, "IX"),
        (5, "V"),
        (4, "IV"),
        (1, "I")
    ]

    for k, v in roman_num_dict:
        while num >= k:
            res += v
            num -= k
        if num == 0:
            return res


if __name__ == "__main__":
    num = 3749
    print(solve(num))
